]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/scroll-view: Add private API to query bar offsets
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 15 Nov 2023 14:06:33 +0000 (15:06 +0100)
committerMarge Bot <marge-bot@gnome.org>
Sat, 18 Nov 2023 18:00:43 +0000 (18:00 +0000)
The scroll fade effect is the only component that accesses the
{v,h}scroll properties for anything other than getting access
to the corresponding adjustments.

Allow the effect to get what it needs via new private API instead,
so we can deprecate and eventually remove the scroll bar properties.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3020>

src/st/st-scroll-view-private.h [new file with mode: 0644]
src/st/st-scroll-view.c

diff --git a/src/st/st-scroll-view-private.h b/src/st/st-scroll-view-private.h
new file mode 100644 (file)
index 0000000..849d832
--- /dev/null
@@ -0,0 +1,30 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * st-scroll-view-private.h: Private StSrollView methods
+ *
+ * Copyright 2023 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "st-scroll-view.h"
+
+G_BEGIN_DECLS
+
+void st_scroll_view_get_bar_offsets (StScrollView *scroll_view,
+                                     float        *hoffset,
+                                     float        *voffset);
+
+G_END_DECLS
index b12c8fd1d05c522ccab5cf216332f739b1d508c8..2a2f19d388fdfc6723e5b0cb277f9a47cfabdb2b 100644 (file)
@@ -60,7 +60,7 @@
 
 #include "st-enum-types.h"
 #include "st-private.h"
-#include "st-scroll-view.h"
+#include "st-scroll-view-private.h"
 #include "st-scroll-bar.h"
 #include "st-scrollable.h"
 #include "st-scroll-view-fade.h"
@@ -1494,3 +1494,27 @@ st_scroll_view_set_policy (StScrollView   *scroll,
 
   g_object_thaw_notify ((GObject *) scroll);
 }
+
+void
+st_scroll_view_get_bar_offsets (StScrollView *scroll,
+                                float        *hoffset,
+                                float        *voffset)
+{
+  StScrollViewPrivate *priv;
+
+  g_return_if_fail (ST_IS_SCROLL_VIEW (scroll));
+
+  priv = st_scroll_view_get_instance_private (scroll);
+
+  if (hoffset)
+    {
+      *hoffset = priv->vscrollbar_visible ? clutter_actor_get_width (priv->vscroll)
+                                          : 0.;
+    }
+
+  if (voffset)
+    {
+      *voffset = priv->hscrollbar_visible ? clutter_actor_get_height (priv->hscroll)
+                                          : 0.;
+    }
+}